unit uChooseContractStatus;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, DB, OracleData, Buttons;

type
  TfmChooseContractStatus = class(TForm)
    odsChooseContractStatus: TOracleDataSet;
    Label1: TLabel;
    cbNewStatus: TComboBox;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
  private
    { Private declarations }
  public
    { Public declarations }
    SelectedStatusId : integer;

    function Execute (startOrderNum : integer) : boolean;
  end;

var
  fmChooseContractStatus: TfmChooseContractStatus;

implementation

{$R *.dfm}

uses uMain;

function TfmChooseContractStatus.Execute(startOrderNum: integer): boolean;
begin
  result := false;

  cbNewStatus.Items.Clear;


  odsChooseContractStatus.Close;
  odsChooseContractStatus.SQL.Text := 'select crst_id id, code, name from contract_statuses where order_num > '+IntToStr(startOrderNum)+' order by order_num';

  odsChooseContractStatus.Open;
  odsChooseContractStatus.First;

  while not (odsChooseContractStatus.eof) do
  begin
    cbNewStatus.Items.AddObject(odsChooseContractStatus.FieldByName('NAME').AsString, TObject(odsChooseContractStatus.FieldByName('ID').AsInteger));

    odsChooseContractStatus.Next;
  end;

  odsChooseContractStatus.Close;

  if cbNewStatus.Items.Count >= 0 then cbNewStatus.ItemIndex := 0;

  if ShowModal = mrOk then
  begin
    SelectedStatusId := integer(cbNewStatus.Items.Objects[cbNewStatus.ItemIndex]);

    result := true;
  end;
end;

end.
